package dnl.jexem.cmd;

import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;

/**
 *
 * @author Daniel Orr
 */
public class BlockingIoHandler implements ProcessIoHandler {

    String out;
    String err;
    
    @Override
    public void handleProcessIO(InputStream standardOut, InputStream standardErr) throws IOException {
        try {
            out = IOUtils.toString(standardOut);
            err = IOUtils.toString(standardErr);
        } finally {
            IOUtils.closeQuietly(standardOut);
            IOUtils.closeQuietly(standardErr);
        }
    }

    @Override
    public String getStandardOut() {
        return out;
    }

    @Override
    public String getStandardErr() {
        return err;
    }

    @Override
    public void kill() {
        
    }

}
